package com.yuncheng.system.sysconfig.service.impl;

import com.yuncheng.common.base.service.impl.CcBaseServiceImpl;
import com.yuncheng.constant.CacheConstant;
import com.yuncheng.system.sysconfig.entity.SysConfig;
import com.yuncheng.system.sysconfig.mapper.SysConfigMapper;
import com.yuncheng.system.sysconfig.service.ISysConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Description: 系统配置表
 * @Author: hbd
 * @Date: 2020-08-30
 * @Version: V1.0
 */
@Service
public class SysConfigServiceImpl extends CcBaseServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {

    private static final Logger log = LoggerFactory.getLogger(SysConfigServiceImpl.class);

    @Resource
    private SysConfigMapper sysConfigMapper;

    @Override
    @Cacheable(value = CacheConstant.SYS_CONFIG_CACHE, key = "#p0")
    public String querySysConfigByCode(String code) {
        //log.info("无缓存sysconfig的时候调用这里");
        return sysConfigMapper.querySysConfigByCode(code);
    }

    @Override
    @CacheEvict(value = CacheConstant.SYS_CONFIG_CACHE, key = "#p0.configCode")
    public boolean updateById(SysConfig sysConfig) {
        return super.updateById(sysConfig);
    }

    @Override
    @CacheEvict(value = CacheConstant.SYS_CONFIG_CACHE, key = "#p0.configCode")
    public boolean save(SysConfig sysConfig) {
        return super.save(sysConfig);
    }
}
